﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Configuration;
using System.Configuration.Provider;

namespace MyDHServer.Compontents.DataProvider
{
    public class CusProviderCollection<T>:ProviderCollection
        where T:ProviderBase
    {
        
        public new T this[string name]
        {
            get
            {
                return (T)base[name];
            }
        }

        public override void Add(ProviderBase provider)
        {
            if (provider == null)
                throw new ArgumentNullException("provider");
            if (!(provider is T))
                throw new ArgumentException
                      ("Invalid provider type", "provider");
            base.Add(provider);
        }
    }

    public class ProvidersConfigSection : ConfigurationSection
    {
        [ConfigurationProperty("providers")]
        public ProviderSettingsCollection Providers
        {
            get
            {
                return (ProviderSettingsCollection)base["providers"];
            }
        }
    }
}
